<?php

namespace App\Http\Middleware;

use Closure;
use Log;

class RequestLog
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure                 $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!$request->isXmlHttpRequest()) {
            Log::info('log_all_request', [
                'METHOD'      => $request->getMethod(),
                'CURRENT_URL' => $request->fullUrl(),
                'REQUEST'     => $request->request->all(),
                'QUERY'       => $request->query->all(),
                'CLIENT_IPS'  => $request->getClientIps(),
                'HEADERS'     => $request->server->getHeaders(),
                'Content'     => $request->getContent(),
            ]);
        }

        return $next($request);
    }
}
